import { card } from './components/index';
import Chart from '@/components/z-charts.vue';
import { dashboardApi } from '@/api/index.js';
import store from '@/store';
import { priceFormat } from '@/utils/base';
import { mapState } from 'vuex';
export default {
	data() {
		return {
			dashboardApi
		};
	},
	components: {
		card,
		Chart
	},
	computed: {
		...mapState({
			globalOrgId: state => state.globalOrg && state.globalOrg.orgId,
			isSubBranch: state => state.user.isSubBranch
		}),
		isCanInit() {
			let { globalOrgId, isAdmin } = this;
			return {
				globalOrgId,
				isAdmin
			};
		}
	},
	created() {},
	props: {
		pageScale: {
			type: [String, Number],
			default: 1
		},
		cardHeight: {
			type: [String, Number],
			default: '200px'
		}
	},
	watch: {
		isCanInit: {
			handler(newV, oldV) {
				if ((this.isAdmin && this.globalOrgId) || !this.isAdmin) {
					if (oldV && newV.globalOrgId === oldV.globalOrgId) {
					} else {
						this.getInfo();
					}
					// console.log('111111111', newV, oldV)
				}
			},
			immediate: true
		}
	},
	methods: {
		priceFormat,
		priceWan(num) {
			return (Math.floor(num / 100) * 100) / 10000;
		}
	}
};
